package com.ly.web.controller.erp;

import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.core.page.TableDataInfo;
import com.ly.common.enums.BusinessType;
import com.ly.heart.domain.AreaEntity;
import com.ly.heart.service.IAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api (value = "Area", tags = "区域")
@RestController
@RequestMapping ("heart/Area")
public class AreaController extends BaseController {

    @Resource
    private IAreaService iAreaService;

    //    @PreAuthorize ("@ss.hasPermi('heart:Area:list')")
    @GetMapping ("/list")
    @ApiOperation ("查询地区")
    public TableDataInfo list (AreaEntity areaEntity) {
        startPage ();
        List<AreaEntity> areaEntities = iAreaService.getList ( areaEntity );
        return getDataTable ( areaEntities );
    }


    @GetMapping ("queryList")
    public AjaxResult queryList (AreaEntity areaEntity) {
        return iAreaService.queryList ( areaEntity );
    }

    /**
     * 新增客户/供应商银行账号信息
     */
    @PreAuthorize ("@ss.hasPermi('heart:Area:add')")
    @Log (title = "地区", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation ("新增地区")
    public AjaxResult add (@RequestBody AreaEntity areaEntity) {
        return toAjax ( iAreaService.saveSingle ( areaEntity ) );
    }

}
